<template>
  <el-row :gutter="15">
    <el-col :span="24" class="mb10">
      <wg-card-eco padding="15px" v-if="props.type == 'card'">
        <template v-slot:title>
          <div class="title-con">
            <el-icon class="icon"><elementStopwatch /></el-icon>
            <div class="title">
              {{ state.title }}
              <img class="img" src="/images/title.png" />
            </div>
          </div>
        </template>
        <div>
          <slot></slot>
        </div>
      </wg-card-eco>
      <div v-else-if="props.type == 'slot'">
        <div class="title-con">
          <el-icon class="icon"><elementStopwatch /></el-icon>
          <div class="title">
            {{ state.title }}
            <img class="img" src="/images/title.png" />
          </div>
        </div>
        <div>
          <slot></slot>
        </div>
      </div>
    </el-col>
  </el-row>
</template>
  
<script setup lang='ts'>
import { getCurrentInstance, onMounted, reactive, watch } from "vue";
const props = defineProps({
  title: {
    type: String,
    default: "",
  },
  type: {
    type: String,
    default: "card",
  },
});
const state = reactive({
  title: "",
});

const init = () => {
  state.title = props.title;
};

onMounted(() => init());
watch(
  () => props.title,
  () => {
    init();
  }
);
</script>
  
<style lang="scss" scoped>
.title-con {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  .icon {
    font-size: 20px;
    color: rgb(95, 209, 76);
    font-weight: 700;
  }
  .title {
    color: #000;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
  }
  .img {
    height: 4px;
    aspect-ratio: auto 100 / 4;
    width: 100px;
  }
}
</style>